package com.education.basic.dao.impl;

import com.yunshangwoniu.core.utils.Logger;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.springframework.stereotype.Component;

import com.education.basic.dao.ScoreDAO;
import com.education.basic.entity.Score;
import com.yunshangwoniu.core.baseDao.impl.BaseDaoImpl;

@Component("scoreDAO")
public class ScoreDAOImpl extends BaseDaoImpl<Score> implements ScoreDAO 
{


    @Override
    public void updateScores(String courseCode,String teacherName,String empno)
    {
        Session session = sessionFactory.getCurrentSession();
        String sql = "update score s set s.teacherName=?,s.empno=? where s.courseCode=?";
        SQLQuery q = session.createSQLQuery(sql);
        q.setString(0,teacherName);
        q.setString(1,empno);
        q.setString(2,courseCode);
        try{
            q.executeUpdate();
            Logger.debug(this.getClass(),String.format("update scores success when courseCode:%s",courseCode));
        }catch (Exception e)
        {
            Logger.warn(this.getClass(),"update score fail!!!!!!!");
        }
    }
}
